package controller.goods;

import util.JdbcDeal;

import javax.swing.*;
import java.sql.SQLException;

public class Goods_del extends JPanel{

    public Goods_del() {
        String table_Gno = JOptionPane.showInputDialog("请输入要删除货物编号）");
        String sql = "DELETE FROM goods WHERE Gno = '" + table_Gno + "'";
        JdbcDeal jdbcDeal = new JdbcDeal();
        try {
            if(jdbcDeal.del(sql) == 1){
                JOptionPane.showMessageDialog(this, "成功删除一条记录！","",JOptionPane.PLAIN_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(this, "删除记录失败！","", JOptionPane.WARNING_MESSAGE);
                return;
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            JOptionPane.showMessageDialog(this, "删除记录失败！可能和其他信息有联动！请先删除相关信息！","", JOptionPane.WARNING_MESSAGE);
        }
    }


}
